package com.tuni.birthdaymoney.web.controller;

import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.tuni.birthdaymoney.web.model.LoginPage;

@Controller
public class LoginController {
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login(Map<String, Object> loginPageMap) {
        LoginPage loginPageModel = new LoginPage();
        loginPageMap.put("loginPageModel", loginPageModel);
        return "login";
    }

    @RequestMapping(value = "/login-error", method = RequestMethod.GET)
    public ModelAndView loginError(@ModelAttribute("loginPageModel") LoginPage loginPageModel) {
        loginPageModel.setHasErrors(true);
        return new ModelAndView("login", "loginPageModel", loginPageModel);
    }
}
